from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import Column, ForeignKey, String, Integer, DateTime,DECIMAL, LargeBinary, create_engine
from sqlalchemy.dialects.mysql import FLOAT
from sqlalchemy.orm import sessionmaker, relationship
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()


# 文件
class Files(Base):
    __tablename__ = 'files'
    id = Column(Integer, primary_key=True, autoincrement=True)
    file_name = Column(String(50))
    data = Column(LargeBinary(length=(2**26)-1))  # 文件最大16M
    create_time = Column(DateTime, nullable=True)
    suffix = Column(String(50))
    size = Column(Integer)
    type = Column(String(50))
    user_id = Column(Integer)
    token = Column(String(50))

    def __init__(self):
        pass

    def __repr__(self):
        return str(self.file_name)



# 参数
class Arguments(Base):
    __tablename__ = 'arguments'
    token = Column(String(50), primary_key=True)
    level_r  = Column(String(50))
    level_h = Column(String(50))
    prob_r = Column(DECIMAL(16,5))
    prob_h = Column(DECIMAL(16,5))
    area1_r = Column(DECIMAL(16,5))
    area2_r = Column(DECIMAL(16,5))
    area3_r = Column(DECIMAL(16,5))
    area4_r = Column(DECIMAL(16,5))
    area1_h = Column(DECIMAL(16,5))
    area2_h = Column(DECIMAL(16,5))
    area3_h = Column(DECIMAL(16,5))
    area4_h = Column(DECIMAL(16,5))
    num1_r = Column(DECIMAL(16,5))
    num2_r = Column(DECIMAL(16,5))
    num3_r = Column(DECIMAL(16,5))
    num4_r = Column(DECIMAL(16,5))
    num1_h = Column(DECIMAL(16,5))
    num2_h = Column(DECIMAL(16,5))
    num3_h = Column(DECIMAL(16,5))
    num4_h = Column(DECIMAL(16,5))
    vld = Column(DECIMAL(16,5))
    vad = Column(DECIMAL(16,5))
    fd = Column(DECIMAL(16,5))
    tor = Column(DECIMAL(16,5))
   

    def __init__(self):
        pass

    def __repr__(self):
        return str(self.file_name)
